package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.MallBillStatusLog;
import com.sc.nft.mapper.MallBillStatusLogMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

/**
 * @author liGen
 * @version 1.0
 * @date 2024/1/23 3:57 下午
 */
@Slf4j
@Repository
public class MallBillStatusLogDao extends ServiceImpl<MallBillStatusLogMapper, MallBillStatusLog> {


    /**
     * 获取账单状态日志
     *
     * @param billId
     * @return
     */
    public MallBillStatusLog getTheLatestStatus(Long billId) {
        LambdaQueryWrapper<MallBillStatusLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MallBillStatusLog::getOrderBillId, billId);
        wrapper.orderByDesc(MallBillStatusLog::getId);
        wrapper.last("limit 1");
        return getOne(wrapper);
    }
}
